package Client.View;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;


public class OnlineUsersPane extends JScrollPane{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5666714762003829426L;
	private JPanel panel;
	int width;
	
	int n=0;
	
	public OnlineUsersPane(int width, int height) {
		this.width = width;
		this.setPreferredSize(new Dimension(width, height));
		
		this.setBackground(LoginFrame.DEFAULT_BG_COLOR);
		
		panel = new JPanel();
		panel.setBackground(LoginFrame.DEFAULT_BG_COLOR);
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		setViewportView(panel);
		setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
	
		panel.setAlignmentY(Component.TOP_ALIGNMENT);
		
		setBorder(new EmptyBorder(5, 5, 5, 5));
		panel.setLayout(null);
	}

	
	public void addPlayerObject(PlayerObject obj){

		int HEIGHT = 40;
		
		obj.setBounds(0, HEIGHT*n, width-2, HEIGHT);
			
		panel.add(obj);
		
		n++;
	}
	
	public void clear(){
		panel.removeAll();
		n = 0;
	}
	
}